﻿using AAA.Base.Util.Reader;

namespace AAA.Command.WCF
{
    public sealed class CommandConfig
    {
        private static CommandConfig _commandConfig;
        private IniReader _iniConfig;

        public static CommandConfig Config()
        {
            if (_commandConfig == null)
                _commandConfig = new CommandConfig();
            return _commandConfig;
        }

        public void Init(string strConfigName)
        {
            _iniConfig = new IniReader(strConfigName);
        }

        public void Init(string strDllFilename, string strFilename)
        {
            _iniConfig = new IniReader(strDllFilename, strFilename);
        }

        public string[] GetCommand(string strCommandName)
        {
            return _iniConfig == null
                    ? new string[0]
                    :   _iniConfig.GetParam(strCommandName) != null
                        ?   _iniConfig.GetParam(strCommandName).Split(',')
                        :   new string[0];

        }
    }
}
